#version 460
#extension GL_GOOGLE_include_directive : enable
#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require

#include "../../../../core/shader_std.h"
#include "../../../../core/shader_built_in_functions.h"
#include "../../../../core/shader_mesh.h"


layout(points) in;
layout(line_strip, max_vertices=32) out;
//layout(points, max_vertices=64) out;




//====================== 顶点阶段输入数据 =====================
layout(location = 1) in VS_GS_VERTEX {
	mat4 vProj;
	mat4 vModel;
	vec4 vCubeColor;
	vec3 vCubePos;
	vec3 vCubeSize;
}vertex_in[];


//======================= 几何阶段输出数据 ========================
layout(location = 0) out vec4 gColor;


void main(void){
	mat4 proj = vertex_in[0].vProj;
	mat4 mat = vertex_in[0].vProj;
	vec4 pos = vec4(vertex_in[0].vCubePos, 1);
	vec3 size = vertex_in[0].vCubeSize;
	//size = vec4(3,3,3,1);

	//gl_Position = proj * mat * vec4(-10,0,0,1);
	//gColor = vertex_in[0].vCubeColor;
	//EmitVertex();
	//gl_Position = proj * mat * vec4(10,1,1,1);
	//gColor = vertex_in[0].vCubeColor;
	//EmitVertex();
	//return;


	vec4 v = pos;
	v.xyz -= size.xyz * 0.5f;
	gl_Position = proj * v;
	gColor = vertex_in[0].vCubeColor;
	EmitVertex();

	v.x += size.x;
	gl_Position = proj * v;
	gColor = vertex_in[0].vCubeColor;
	EmitVertex();
	
	v.z += size.z;
	gl_Position = proj * v;
	gColor = vertex_in[0].vCubeColor;
	EmitVertex();

	v.x -= size.x;
	gl_Position = proj * v;
	gColor = vertex_in[0].vCubeColor;
	EmitVertex();

	v.z -= size.z;
	gl_Position = proj * v;
	gColor = vertex_in[0].vCubeColor;
	EmitVertex();
	EndPrimitive();

	v = pos;
	v.xyz += size.xyz * 0.5f;
	gl_Position = proj * v;
	gColor = vertex_in[0].vCubeColor;
	EmitVertex();

	v.z -= size.z;
	gl_Position = proj * v;
	gColor = vertex_in[0].vCubeColor;
	EmitVertex();

	v.x -= size.x;
	gl_Position = proj * v;
	gColor = vertex_in[0].vCubeColor;
	EmitVertex();

	v.z += size.z;
	gl_Position = proj * v;
	gColor = vertex_in[0].vCubeColor;
	EmitVertex();

	v.x += size.x;
	gl_Position = proj * v;
	gColor = vertex_in[0].vCubeColor;
	EmitVertex();
	EndPrimitive();

	v = pos;
	v.xyz -= size.xyz * 0.5f;
	gl_Position = proj * v;
	gColor = vertex_in[0].vCubeColor;
	EmitVertex();

	v.y += size.y;
	gl_Position = proj * v;
	gColor = vertex_in[0].vCubeColor;
	EmitVertex();
	EndPrimitive();

	v.x += size.x;
	gl_Position = proj * v;
	gColor = vertex_in[0].vCubeColor;
	EmitVertex();

	v.y -= size.y;
	gl_Position = proj * v;
	gColor = vertex_in[0].vCubeColor;
	EmitVertex();
	EndPrimitive();

	v.z += size.z;
	gl_Position = proj * v;
	gColor = vertex_in[0].vCubeColor;
	EmitVertex();
	
	v.y += size.y;
	gl_Position = proj * v;
	gColor = vertex_in[0].vCubeColor;
	EmitVertex();
	EndPrimitive();

	v.x -= size.x;
	gl_Position = proj * v;
	gColor = vertex_in[0].vCubeColor;
	EmitVertex();
	
	v.y -= size.y;
	gl_Position = proj * v;
	gColor = vertex_in[0].vCubeColor;
	EmitVertex();
	EndPrimitive();

}

 